<template>
  <div>
    <div class="outer">
      <h1>App</h1>
      <List @atguigu="getListData" />
    </div>
  </div>
</template>
<script>
import _ from "lodash";
import List from "@/components/List";
export default {
  name: "App",
  data() {
    return {
      List: [],
    };
  },
  components: {
    List,
  },
  methods: {
    //自定义事件回调函数，主要用于接收子组件的传参(子向父传值)
    getListData(list) {
      //拿到数据保存在data上，最好给一个新的值(需要拷贝)
      // this.List = [...list]
      //数据复杂时，可以考虑深拷贝 用lodash包
      this.List = _.cloneDeep(list);
      //判断深浅拷贝
      console.log(this.List[0] === list[0]);
    },
  },
};
</script>

<style>
.outer {
  height: 400px;
  background: red;
}
</style>